/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package module;

import java.util.Comparator;
import wargame.entity.Bid;
import wargame.entity.Player;
import wargame.dao.PlayerDAO;

/**
 *
 * @author stanley.2007
 */
public class BidComparator implements Comparator<Bid> {

    @Override
    public int compare(Bid bid1, Bid bid2) {
        int player1_amount = bid1.getAmount();
        int player2_amount = bid2.getAmount();
        Player p1 = PlayerDAO.retrievePlayer(bid1.getPlayer_id());
        Player p2 = PlayerDAO.retrievePlayer(bid2.getPlayer_id());
        int player1_trackRecord = p1.getTrack_record_points();
        int player2_trackRecord = p2.getTrack_record_points();

        double value1 = 0;
        double value2 = 0;
        value1 = (player1_amount * 0.6) - (player1_trackRecord * 0.4);
        value2 = (player2_amount * 0.6) - (player2_trackRecord * 0.4);

        //ascending order
        if (value1 > value2) {
            return +1;
        } else if (value1 < value2) {
            return -1;
        } else {
            return 0;
        }


    }
}
